package com.durian.finance.service.impl;

import com.durian.common.core.utils.DateUtils;
import com.durian.financial.api.domain.FkBusinessCredit;
import com.durian.finance.mapper.FkBusinessCreditMapper;
import com.durian.finance.service.IFkBusinessCreditService;
import com.durian.financial.api.domain.FkBusinessCreditSub;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 风控公寓授信主Service业务层处理
 * 
 * @author durian
 * @date 2022-06-28
 */
@Service
public class FkBusinessCreditServiceImpl implements IFkBusinessCreditService 
{
    @Autowired
    private FkBusinessCreditMapper fkBusinessCreditMapper;

    /**
     * 查询风控公寓授信主
     * 
     * @param id 风控公寓授信主主键
     * @return 风控公寓授信主
     */
    @Override
    public FkBusinessCredit selectFkBusinessCreditById(Long id)
    {
        return fkBusinessCreditMapper.selectFkBusinessCreditById(id);
    }

    /**
     * 查询风控公寓授信主列表
     * 
     * @param fkBusinessCredit 风控公寓授信主
     * @return 风控公寓授信主
     */
    @Override
    public List<FkBusinessCredit> selectFkBusinessCreditList(FkBusinessCredit fkBusinessCredit)
    {
        return fkBusinessCreditMapper.selectFkBusinessCreditList(fkBusinessCredit);
    }

    /**
     * 新增风控公寓授信主
     * 
     * @param fkBusinessCredit 风控公寓授信主
     * @return 结果
     */
    @Override
    public int insertFkBusinessCredit(FkBusinessCredit fkBusinessCredit)
    {
        fkBusinessCredit.setCreateTime(DateUtils.getNowDate());
        return fkBusinessCreditMapper.insertFkBusinessCredit(fkBusinessCredit);
    }

    /**
     * 修改风控公寓授信主
     * 
     * @param fkBusinessCredit 风控公寓授信主
     * @return 结果
     */
    @Override
    public int updateFkBusinessCredit(FkBusinessCredit fkBusinessCredit)
    {
        return fkBusinessCreditMapper.updateFkBusinessCredit(fkBusinessCredit);
    }

    /**
     * 批量删除风控公寓授信主
     * 
     * @param ids 需要删除的风控公寓授信主主键
     * @return 结果
     */
    @Override
    public int deleteFkBusinessCreditByIds(Long[] ids)
    {
        return fkBusinessCreditMapper.deleteFkBusinessCreditByIds(ids);
    }

    /**
     * 删除风控公寓授信主信息
     * 
     * @param id 风控公寓授信主主键
     * @return 结果
     */
    @Override
    public int deleteFkBusinessCreditById(Long id)
    {
        return fkBusinessCreditMapper.deleteFkBusinessCreditById(id);
    }

    /**
     * 根据商户id获取 风控公寓授信对象
     *
     * @param businessId 商户id
     * @return FkBusinessCredit（风控公寓授信对象）
     */
    @Override
    public FkBusinessCredit getByBusinessId(Long businessId) {
        return fkBusinessCreditMapper.getByBusinessId(businessId);
    }

    /**
     * 根据商户id 和 金融产品id查询
     *
     * @param businessId
     * @param jrProductId
     * @return
     */
    @Override
    public FkBusinessCreditSub getSubByBusinessIdAndProductId(Long businessId, Long jrProductId) {
        return fkBusinessCreditMapper.getSubByBusinessIdAndProductId(businessId.intValue(),jrProductId.intValue());
    }


    /**
     * 修改风控公寓授信子
     *
     * @param fkBusinessCreditSub 风控公寓授信子
     * @return 结果
     */
    @Override
    public int updateFkBusinessCreditSub(FkBusinessCreditSub fkBusinessCreditSub)
    {
        return fkBusinessCreditMapper.updateFkBusinessCreditSub(fkBusinessCreditSub);
    }

}
